#pragma once
#include <objidl.h>

class MessageFilter: public IMessageFilter
{
public:
	MessageFilter(void);
	~MessageFilter(void){::CoRegisterMessageFilter(NULL, NULL);}

    STDMETHODIMP_(DWORD) HandleInComingCall(DWORD dwCallType,HTASK threadIDCaller,DWORD dwTickCount,LPINTERFACEINFO lpInterfaceInfo)
    {
		return NULL;
        ////we CANNOT reject these calls
        //if(dwCallType == CALLTYPE_ASYNC_CALLPENDING || dwCallType == CALLTYPE_ASYNC)
        //{
        //    return SERVERCALL_ISHANDLED;
        //}

        //T* pT = static_cast<T*>(this);
        //return pT->ProcessInComingCall(dwCallType,threadIDCaller,dwTickCount,lpInterfaceInfo);
    }

    STDMETHODIMP_(DWORD) MessagePending(HTASK threadIDCallee,DWORD dwTickCount,DWORD dwPendingType)
    { return PENDINGMSG_WAITNOPROCESS; }

    STDMETHODIMP_(DWORD) RetryRejectedCall(HTASK threadIDCallee,DWORD dwTickCount,DWORD dwRejectType)
    {
		return -1;
        //if(dwRejectType == SERVERCALL_REJECTED) { return -1; }
        //return dwTimeOut;
    }
};
